Fixed warnings and added comments