Fixins

some bugfixes, discovered via php error log.