Refactor and small comments