Updated to 1.4.0 API, fixed some bugs