Refactor and tuning.
Extended to support the problem marker.