Cleaned up the palette code

Removed a platform specific Mono bug workaround and did otherwise only minor source code formatting.