Issue 491, use long instead of int for the timeout related APIs. Merged Nandor Kracser <bonifaido@gmail.com> changes plus some minor changes.