Shortened code and added debug booleans