applied patches from Tim Pinet https://issues.apache.org/jira/browse/SANDBOX-259 https://issues.apache.org/jira/browse/SANDBOX-258