A lot of refactoring and bugfixing for the ImgData Class