Initial commit, refactoring original library. Both sample scripts still run correctly