Logic fix.
Almost releaseable state. Some formatting is left to do.