Work-around for a weird bug + minor code clean up