Some corrections and delete unused code