fix #1, other improvements

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>