Fixed dirname and refactored REPO_SRC to castle level