Cleaned up code. Unfortunately, running is broken now