Bug fixes and support for challenges

Probably mostly redundant with Joseph's fixes...