wip: Code cleaning and adding documentation/comments