Yeah you've pointed out one of the serious design flaws with the current custom layer API :(
You'll have more success if you use a single command map for everything and do your own if/else or switch type dispatching on global state variables that you create yourself.
is the best example of how it looks when you use this method and contains handy macros that you might be able to use as-written to setup your bindings.