Cleaning and API

Added time utils and implemented some cookie functions to the API, made
a class for plugins to extend from and cleaned the code a bit