Fixed a few errors and tested the functions to make sure they work. You
should be able to do your stuff now.