Fixed bugs, added mac os target

Added Mac OS target.
Fixed bugs running on bigger devices.
General code improvements and bug fixes