Pre beta 1.51 delivery

All the functions were encapsulated inside the main function and the
last result is returned.