RoDi: big code clean-up
RoDi: big code clean-up

Move all repeated code to global functions, fix coding styles, etc.

walterbender/turtleblocksjs,hemantkasat/turtleblocksjs,Daksh/turtleblocksjs,garyservin/turtleblocksjs,i5o/turtleblocksjs,i5o/turtleblocksjs,tradzik/turtleblocksjs,rodibot/turtleblocksjs,rodibot/turtleblocksjs,hemantkasat/turtleblocksjs,walterbender/turtleblocksjs,tchx84/turtleblocksjs,Daksh/turtleblocksjs,hemantkasat/turtleblocksjs,walterbender/turtleblocksjs,Daksh/turtleblocksjs,i5o/turtleblocksjs,tchx84/turtleblocksjs,garyservin/turtleblocksjs,tradzik/turtleblocksjs,tchx84/turtleblocksjs,garyservin/turtleblocksjs,tradzik/turtleblocksjs,rodibot/turtleblocksjs