reduce memory consumption, bugfix