Fixed problems 5 and 12, cleaned up code

also changed calculations timing to be more accurate and to use a more
sensible measurement.