         message: err.message
         stack: err.stack
 
-send_error_socket = (err) ->
+sendErrorSocket = (err) ->
     console.log "Sending error through socket"
     console.log err.stack
     #compound.io.sockets.emit 'installerror', err.stack
 
-mark_broken = (res, app, err) ->
+markBroken = (res, app, err) ->
     console.log "Marking app #{app.name} as broken because"
     console.log err.stack
 

    stop: (req, res, next) ->
        manager = new AppManager
        manager.stop req.application, (err, result) ->
            return mark_broken res, req.application, err if err

            data =
                state: 'stopped'
                port : 0

            req.application.updateAttributes data, (err) ->
                return send_error res, err if err

                manager.resetProxy (err) ->
                    return mark_broken res, req.application, err if err
                    res.send
                        success: true
                        msg: 'Application stopped'

    app.password = null
    app.errormsg = err.message
    app.save (saveErr) ->
        return sendError res, saveErr if saveErr

        res.send
            app: app
