Cleaned up code a bit, no functional changes