several improvements in code. v0.9