further corrections and cleanup