Merged from master + few bug fixes.