Move code into a utilities class, add LowSpaceException

Trying to make everything a bit cleaner