Factories added, some exception handling.