First part of console and gui merge