lots of bugfixes and code optimization

also adds score.