Moved code into a separate place, added scaling and stuff. TODO: magnifying mouse