manager.c: created first version of code

Logic completed but there are still some things to do (see //TODO:)