Removed trace logging. Fixed bugs and errors.