refactor of engine, input and renderer