bugfixes; reworked some stuff