added on devel notes, cleaned up debugging and tidied up the code