Added 'callbacks on main thread' functionality
Various fixes. screenptr added