refactor OSD code and PCNT stuff