Code version 3, bug fixes, comments, TODOLIST and some extra functions