Added python binding, fixed some errors