Added play/pause/restart functions, tidied up code and fixed an issue where timer was not stopping on one of the conditions.