Fix firefox

Fixed errors with Firefox (issue #42). Still unusably slow, though, will require optimization.