Some fixes and modifications