Cleaned up code, renamed variables.