Fixes, cleanup and general improvement.