Cleaned up solver; added comments.