Further re-arrange actions

Move logic form .mak to Python, this will allow
to easily add more action cases in the future.