Annotate code and fix sessions middleware