Some improvements on the original plugin by Jarrod Lowe