Cleaned up code, commenting functions