Added fixes for bugs where the previous and next filaments don't exist to make sure we don't append or prepend them.