Added fix for http://issues.apache.org/activemq/browse/AMQ-1014 and http://issues.apache.org/activemq/browse/AMQ-1002