Fixed method for extracting strings
Fixed wrong module state parsing. Fixes #478
Added condition for terminating console. Fixed  #517