General fixes and cleanup