Made the code a bit easier to read, by adding comment "boundaries" to the code
(for example, something like //---- FUNCTION DEFINITIONS ----\\). Improved
session management.