Added remove all notes from chapter option and added check for invalid note reference
Fixed close chapter method to correctly detect active chapter