Added missing statement that imports reshape library

Plus some additional bugfixes and tweaks