Fix for some issues (please review before merging)