Code cleaning

I cleaned the code to respect the Ruby style-guides, some parts are still a bit weird though.
Along the way, I changed some methods by splitting them in sub-private-methods but I kept the API intact.