several improvements. still buggy