Refactor into functions and patterns only
Merge pull request #1 from masteinhauser/functions

Refactor into functions and patterns only