Refactor note handling