Bug fixing template, clean up old code