platform specific bug fixes & code cleanup