Bug fixes and platform cleanup