Addressed the bugs @madmaxoft pointed out.

Signed-off-by: netchip <w00tc0d3@outlook.com>