Code review and improvements