Updated with some bugfixes