Last_online fix and some code cleanup