Fixed Issue #4 and removed hgapi dependency