Improvements, bugfixes, optimize imports, reformat