Tidied up subroutines, added constants file