Remove lapi and fix bugs