JS positioning bug fixing and cleanup