Implement expand

Implementation of expand, closes #127.