Codereview done, moved functions, removed whitespaces, edited comments. Nothing big or special