robustness/code style changes
supposed to fix #296