Fixed some bugs in the lib

Signed-off-by: Herbert <herberthb12@gmail.com>