Add multilayer support

Networks with a variable number of medial layers can be simulated with
the implementation