less mess with mainloop

fixes some weird bugs