Added some new functions. Cleaned up a little.