Partial rewrite of a couple of files

A major rewrite was recently committed (https://github.com/wei2912/bce-simulation/commit/a96c32a46db95dba2a5a11c530d098390293e153), hence the need for a full code review and system test to ensure that everything is working.