Added prefix solver and refactored. Bug in prefix solver.