Minor fixes, removed unused code etc.