Converted to RailsApp, moved funcionality to models, simplified script, included Modules