Bug fixes

Also remove useless example code.