refact + solver + fix bugs