Refactored code to use more code from tori-bundle