cleaned up code a bit, wrote solver