Formated code new, added some debug-messages