Removed a lot of redundant code.