Intermediate cleaning, added comments, descriptions and removed some ugly or deprecated code