Refactor code

wrapped up all constructors to make it more cleaner, rearranged code in
ContextManager