Organizing code, some small new features, bugfixes