refine infrastructure, some progress in sdl
improve input loop