Rehandled special case of n as 0, some input fixes and increased modularity