PLAT-4705 - Bug fixes and minor refactoring