Adding some helpers to system and refactoring where appropriate.