Some refactoring and fixes for VLC