Cleaned up the code. This object actually needs a rewrite.