Added more old code from previous incarnation