Some fixes and added comments