Code update from original project.