cleaned up source and make android compatiable