Misc changes, first working version