Moved all reusable functions to a sepperate file.