Refactor and VBS fixes