Implement expand

Implementation of expand, closes #127.
This should be indented.