Various Fixes

Fixes and code rework.