Finish first version (still rather buggy)