externalized js, some bugfixes