fixed #214 and #185

Signed-off-by: Marcin Wiatr <mail.wichura@gmail.com>