Cleaned up code for merge