Cleaned up code and removed some old unused lines.