added debug system and more comments + readability