Replaced Ruby/SQL clear and init with pure SQL
First pass tidy up