Fixed issues #1 and #4.

Issue #1: Added methods as per the description.
Issue #4: Applied patch from the description.