Cleaned up some bugs and excess code.