Refactor (more reliable and logical)—count basics finished

ref #40