anchor.diff:  
   create(App) ->
     case new(App) of
  -    NewApp when is_record(NewApp, app) -> 
  +    NewApp when is_record(NewApp, app) ->
         ValidAppWithName = validate_unique_name(NewApp),
         NewApp1 = validate_app(ValidAppWithName),
         save(NewApp1);
  
positive.code: validate_app(App) when is_record(App, app) -> validate_app(record_info(fields, app), App).
  validate_app([], App) ->  App;
  
  % Validate the branch
  validate_app([branch|Rest], #app{branch = undefined} = App) -> validate_app(Rest, App#app{branch = "master"});
  validate_app([branch|Rest], #app{branch = _V} = App) -> validate_app(Rest, App);
  % Validate the url
  validate_app([url|Rest], #app{url = _Url} = App) -> validate_app(Rest, App);
  % Validate the type, it can only be either static or dynamic
  validate_app([vcs_type|Rest], #app{vcs_type = git} = App) -> validate_app(Rest, App);
  validate_app([vcs_type|Rest], #app{vcs_type = _Else} = App) -> validate_app(Rest, App#app{vcs_type = git});
  % Validate the timeout
  validate_app([timeout|Rest], #app{timeout = undefined} = App) -> validate_app(Rest, App#app{timeout = 10*1000});
  validate_app([timeout|Rest], #app{timeout = V} = App) -> validate_app(Rest, App#app{timeout = misc_utils:to_integer(V)*1000});
  % Validate the sticky parameter
  validate_app([sticky|Rest], #app{sticky = "true"} = App) -> validate_app(Rest, App#app{sticky = true});
  validate_app([sticky|Rest], #app{sticky = _Else} = App) -> validate_app(Rest, App#app{sticky = false});
  % Validate min/max instances
  validate_app([min_instances|Rest], #app{min_instances = undefined} = App) -> validate_app(Rest, App#app{min_instances = 1});
  validate_app([min_instances|Rest], #app{min_instances = V} = App) -> validate_app(Rest, App#app{min_instances = misc_utils:to_integer(V)});
  validate_app([max_instances|Rest], #app{max_instances = undefined} = App) -> validate_app(Rest, App#app{max_instances = 1});
  validate_app([max_instances|Rest], #app{max_instances = V} = App) -> validate_app(Rest, App#app{max_instances = misc_utils:to_integer(V)});
  % Validate the template
  validate_app([template|Rest], #app{template = undefined} = App) -> validate_app(Rest, App#app{template = default});
  validate_app([template|Rest], #app{template = Val} = App) -> validate_app(Rest, App#app{template = misc_utils:to_atom(Val)});
  % Validate the routing parameter
  validate_app([routing_param|Rest], #app{routing_param = undefined} = App) -> validate_app(Rest, App#app{routing_param = 'Host'});
  validate_app([routing_param|Rest], #app{routing_param = V} = App) -> validate_app(Rest, App#app{routing_param = misc_utils:to_atom(V)});
  % Validate others?
  validate_app([_H|Rest], App) -> validate_app(Rest, App).
  
  
  
negative.code:   StdErr     = filename:join([LogDir, "beehive.err"]),
  
    lists:flatten([
                   build_env({name, App#app.name}),
                   build_env({repos, App#app.url}),
                   build_env({revision, App#app.revision}),
                   build_env({path, BeehivePath}),
                   build_env({branch, App#app.branch}),
                   {stdout, StdOut},
                   {stderr, StdErr},
                   OtherEnvs
                  ]).
  
  build_env({Key, Value}) ->
    RealValue = case Value of
                  undefined -> "undefined";
                  _ -> Value
                end,
    T = lists:flatten([
                       string:to_upper(erlang:atom_to_list(Key)),
                       "=",RealValue,""
                      ]),
    {env, T}.
  
  %% If erlang had 'meta-programming,' we wouldn't have to do all this work to validate the proplists
  from_proplists(Proplists) -> from_proplists(Proplists, #app{}).
  from_proplists([], App)  -> App;
  from_proplists([{name, V}|Rest], App) -> from_proplists(Rest, App#app{name = V});
  