Implement saving lastLevel in database re #627

Hope this is okay