extracted and finished actionManager script
moved action handling in middleware to its own script
added check for unauthorised middleware access
minor styling
removed unneeded import