added parsing from memory; some code cleaning