Code Refactor + rpanel fixes