MDL-46218 core_notes: rearranged security checks for clarity and did some coding style clean up