Added helper methods to main code

No functional change. Just a tidy up.