fixes bugs listed at nerdnu/nerdbugs/#117
fixes bugs listed at nerdnu/nerdbugs/#117