Support nested bindings and nested expressions in record generation

Fix #415.