Fix some API bugs