Bug Fixes

Fixed API Bug, and fixed sorting bug