fix warnings
tried to share more code between platforms