cleanup and add console support