ported core

I hope I didn't miss anything, haven't tested it yet.
All was ported, except the 404 handler (to my knowledge)
Merge pull request #1 from happyDemon/master

ported core