Code cleaning

Comments + refactored + modularized