PLAT-4705 - More bug fixes and refactoring