WIP: Cleaning code

Cleaning the code, adding docstring, making it beautiful.