Add missing directory OS code, bug fixes