Fixed performance issues on the implementation of Issue #608