Adapted source code from old project dir.