fix memory leak in issue #18
fix compiler warnings/errors
fix compile with non-static builds
Merge pull request #29 from aseigo/master

compiler and memory leak fixes