Implement more primitives and foreign lib functions