Updated version with some bugfixes