Some cleanup, and added examples of taking functions as parameters