Refactoring of the brick execution logic and correction of errors.