Fixed Issue #315 and #316