General bug fixing and small aditions