reshape and flatten. fixes #32