merged handleMessage and handleInit and general polishing