If the enemy is going inside the wall, check the size of your collision cells for the path finding behaviour. I assume you're using the path finding behaviour for moving the enemy to this "last seen object" you have?
Also check the collision bounds of the wall objects and the enemy character too, and make sure they're good.
To make the enemy go exactly on the object - check for a close distance (proximity) on the object... once you have this close distance (after using path finding) then turn path finding off and use "moveto" behaviour or some other movement method to go straight to final position. The path finding will work when the enemy is far away (so it will avoid walls and such) but then move to the exact place once within your defined distance (10-20 pixels maybe?).
~Sol
I didn't use the path finding behavior, because it doesn't work. The first time the enemy is assigned to find a path, he does and moves like 30 pixels and then stops. Second time he just keeps calculating.