changed return methods to int
return a positive number on success
a negative number for fails.

fixed some typos
(cherry picked from commit 7cf68de)