Fixed unresolved variable. Cleaned up code.