Reworked session handlers. Added draft of static API