Fixed issues reported in 4909 and 4914

Code changes to resolve GEOT-4909 and GEOT-4914.