RT, IN | #1558 | added changes to manage sessions and a whole lot of refactoring