Improved and re-structured some Javascript functions in annotations page