Moved code into separate libraries