ported core

I hope I didn't miss anything, haven't tested it yet.
All was ported, except the 404 handler (to my knowledge)