Issue #9: Improved cache handling and added comments.