Added regularization and ability to output multiple files